package sing.cloud.alibaba.seata.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import sing.cloud.alibaba.seata.domain.CommonResult;
import sing.cloud.alibaba.seata.service.IAccountService;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author xing
 * @date 2022/9/3 18:49
 */
@RestController("accountController")
public class AccountController {
    @Resource
    private IAccountService accountService;

    /**
     * 扣减账户余额
     */
    @RequestMapping("/account/decrease")
    public CommonResult decrease(@RequestParam("userId") Long userId, @RequestParam("money") BigDecimal money){
        accountService.decrease(userId, money);
        return new CommonResult(200,"扣减账户余额成功！");
    }
}
